{% extends 'wiki/base.html' %}

{% if page_path %}
    {% set page_title = _('All pages in %(page_name)s', page_name=page_name) %}
    {% set feed_link = url_for('wiki/list-atom', page_path=page_path) %}
{% else %}
    {% set page_title = _('All Pages') %}
    {% set feed_link = url_for('wiki/list-atom') %}
{% endif %}

{% block title %}{{ page_title }} - {{ sitename }}{% endblock %}

{%- block extrahead -%}
    {{- super() -}}
    <link type="application/atom+xml" rel="alternate" href="{{ feed_link }}" title="{{ _('Atom feed for this page') }}">
{% endblock %}

{% block content %}
    <h1>
        {{ page_title }}
        <ul class="actions">
            <li><span class="icon icon-feed"></span> <a href="{{ feed_link }}" title="{{ _('Atom feed for this page') }}">{{ _('Feed') }}</a></li>
        </ul>
    </h1>
    {% if pages %}
        {% if page_path %}
            <p>{% trans url=url_for('wiki/index', page_path=page_path), page_name=revision.title %}Here is a list of all children pages of <a href="%(url)s">{{ page_name }}</a>.{% endtrans %}</p>
        {% else %}
            <p>{{ _('Here is a list of all pages available in this wiki.') }}</p>
        {% endif %}
        <table class="grid" id="wiki-list">
            <tbody>
            {% set row_class = cycler('odd', 'even') %}
            {% for page in pages %}
                <tr class="{{ row_class.next() }}">
                    <td>
                        <span class="icon icon-page"></span> <a href="{{ url_for('wiki/index', page_path=page.path) }}">{{ page.path }}</a>
                    </td>
                    <td class="page-children">
                        <span class="icon icon-folder"></span> <a href="{{ url_for('wiki/list', page_path=page.path) }}" title="{{ _('Children pages of this page') }}">{{ _('Children') }}</a>
                    </td>
                    <td class="page-history">
                        <span class="icon icon-wait"></span> <a href="{{ url_for('wiki/changes', page_path=page.path) }}" title="{{ _('Change history for this page') }}">{{ _('History') }}</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
            {% if not is_first_page or next_page %}
            <tfoot>
                <tr>
                    <td colspan="2">
                        {% if not is_first_page %}
                            &larr; <a href="javascript:history.back();">{{ _('previous page') }}</a>
                        {% endif %}
                        {% if not is_first_page and next_page %} | {% endif %}
                        {% if next_page %}
                            <a href="{{ url_for('wiki/list', start=next_page, page_path=page_path) }}">{{ _('next page') }}</a> &rarr;
                        {% endif %}
                    </td>
                </tr>
            </foot>
            {% endif %}
        </table>
    {% else %}
        {% if page_path %}
            <p>{{ _("This page doesn't have any children pages.") }}</p>
        {% else %}
            <p>{{ _("This wiki still doesn't have any pages.") }}</p>
        {% endif %}
    {% endif %}
{% endblock %}
